/* 
 * File:   FractalMandel.cpp
 * Author: amouro-m
 * 
 * Created on 15 mai 2010, 01:29
 */

#include <stdio.h>
#include "FractalMandel.hpp"

FractalMandel::FractalMandel(unsigned int iter_max):
Fractal(-2, 2, -2, 2),
_iter_max(iter_max)
{}

FractalMandel::~FractalMandel() {}

Uint32
FractalMandel::compute(const double x, const double y) const
{
    double        zx = 0, zy = 0, tmp;
    unsigned int  i = 0;

    for (i = 0; (zx*zx + zy*zy) <= _bail && i < _iter_max; ++i)
    {
        tmp = zx*zx - zy*zy + x;
        zy = 2*zx*zy + y;
        zx = tmp;
    }

    return i;
}